import * as qiankun from 'qiankun';

console.log('0-0-0-0-0----', qiankun);

const state = {
  num: 1
};

// 初始化 state
const actions = qiankun.initGlobalState(state);

actions.onGlobalStateChange((state, prev) => {
  // state: 变更后的状态; prev 变更前的状态
  console.log('主应用检测到state变更：', state, prev);
});

// 你还可以定义一个获取state的方法下发到子应用
actions.getGlobalState = function () {
  return state
}

export default actions;
